#include <bits/stdc++.h>
using namespace std;
#define IOS() ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define int long long
#define pb(x) push_back(x)
#define mp make_pair
#define fir first
#define se second
#define pii pair<int,int>
int a[100005],d[100005],v[100005],p[100005],vis[100005];
pii se[100005];
signed main(){;
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    IOS();
    int t=1;
    cin>>t;
    while(t--){
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
            cin>>d[i]>>v[i]>>a[i],vis[i]=0;
        for(int i=1;i<=m;i++)
            cin>>p[i];
        sort(p+1,p+m+1);
        int ans1=0;
        for(int i=1;i<=n;i++){
            if(p[m]<d[i])
                continue;
            // if(v[i]>V)
            //     ans1++;
            if(a[i]>=0){
                int fa=p[m];
                int v1=v[i]*v[i]+2*a[i]*(fa-d[i]);
                if(v1>V*V)
                    ans1++,vis[i]=1;
            }
            else{
                int fa=0;
                int l=1,r=m;
                while(l<=r){
                    int mid=l+r>>1;
                    if(p[mid]>=d[i])
                        fa=mid,r=mid-1;
                    else
                        l=mid+1;
                }
                int v1=v[i]*v[i]+2*a[i]*(p[fa]-d[i]);
                if(v1>V*V)
                    ans1++,vis[i]=1;
            }
        }
        cout<<ans1<<" ";
        int tot=0;
        for(int i=1;i<=n;i++){
            if(!vis[i])
                continue;
            int fi=0;
            int l=1,r=m;
            while(l<=r){
                int mid=l+r>>1;
                if(p[mid]>=d[i])
                    fi=mid,r=mid-1;
                else
                    l=mid+1;
            }
            if(a[i]<0){
                int fa=0;
                l=fi,r=m;
                while(l<=r){
                    int mid=l+r>>1;
                    if(v[i]*v[i]+2*a[i]*(p[mid]-d[i])>V*V)
                        fa=mid,l=mid+1;
                    else
                        r=mid-1;
                }
                se[++tot]=mp(fi,fa);
            }
            else{
                int fi1;
                l=fi,r=m;
                while(l<=r){
                    int mid=l+r>>1;
                    if(v[i]*v[i]+2*a[i]*(p[mid]-d[i])>V*V)
                        fi1=mid,r=mid-1;
                    else
                        l=mid+1;
                }
                se[++tot]=mp(fi1,m);
            }
        }
        sort(se+1,se+tot+1);
        // for(int i=1;i<=tot;i++)
        //     cout<<se[i].fir<<" "<<se[i].se<<"\n";
        int nw=1,ans2=0;
        // cout<<1<<endl;
        while(nw<=tot){
            int mn=1e18;
            for(int i=nw;i<=tot;i++){
                if(se[i].fir>mn){
                    nw=i;
                    break;
                }
                if(i==tot)
                    nw=tot+1;
                mn=min(mn,se[i].se);
            }
            ans2++;
            // cout<<nw<<"\n";
        }
        cout<<m-ans2<<endl;
    }
    return 0;
}